package com.baizhi.service.impl;


import com.baizhi.dao.ProductDao;
import com.baizhi.entity.Product;
import com.baizhi.service.ProductService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductDao pd;


    @Override
    public PageInfo<Product> selectPage(int page, int limit) {
        PageHelper.startPage(page,limit);
        List<Product> productList = pd.selectList(null);

        return  new PageInfo<>(productList);
    }

    @Override
    public void delete(int id) {
        pd.deleteById(id);
    }

    @Override
    public void deleteBatchIds(List<Integer> ids) {
    pd.deleteBatchIds(ids);
    }

    @Override
    public void insert(Product product) {
        pd.insert(product);
    }

    @Override
    public void update(Product product) {
        pd.updateById(product);
    }
}
